package com.kingdee.jdy.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class SalOrderController {

    public static JSONObject prepareSalOrderParam(long unitid, long customerid_id, long materialid_id, long stockid_id) throws Exception{

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = simpleDateFormat.format(new Date());

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", null);
        jsonObject.put("billdate", dateStr);
        jsonObject.put("customerid_id", customerid_id);

        JSONArray material_entityArray = new JSONArray();
        JSONObject entity = new JSONObject();
        entity.put("id", null);
        entity.put("materialid_id", materialid_id);
        entity.put("unit_id", unitid);
        entity.put("price", 1);
        entity.put("qty", 2);
        entity.put("stockid_id", stockid_id);
        entity.put("deliverydate", dateStr);

        material_entityArray.add(entity);

        jsonObject.put("material_entity", material_entityArray);

        return jsonObject;
    }
}
